<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module OpenSSL::Buffering - openssl: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><span class="include">Enumerable</span>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li class="calls-super" ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-3C-3C">#&lt;&lt;</a>
    <li ><a href="#method-i-close">#close</a>
    <li ><a href="#method-i-consume_rbuff">#consume_rbuff</a>
    <li ><a href="#method-i-do_write">#do_write</a>
    <li ><a href="#method-i-each">#each</a>
    <li ><a href="#method-i-each_byte">#each_byte</a>
    <li ><a href="#method-i-each_line">#each_line</a>
    <li ><a href="#method-i-eof">#eof</a>
    <li ><a href="#method-i-eof-3F">#eof?</a>
    <li ><a href="#method-i-fill_rbuff">#fill_rbuff</a>
    <li ><a href="#method-i-flush">#flush</a>
    <li ><a href="#method-i-getbyte">#getbyte</a>
    <li ><a href="#method-i-getc">#getc</a>
    <li ><a href="#method-i-gets">#gets</a>
    <li ><a href="#method-i-print">#print</a>
    <li ><a href="#method-i-printf">#printf</a>
    <li ><a href="#method-i-puts">#puts</a>
    <li ><a href="#method-i-read">#read</a>
    <li ><a href="#method-i-read_nonblock">#read_nonblock</a>
    <li ><a href="#method-i-readchar">#readchar</a>
    <li ><a href="#method-i-readline">#readline</a>
    <li ><a href="#method-i-readlines">#readlines</a>
    <li ><a href="#method-i-readpartial">#readpartial</a>
    <li ><a href="#method-i-ungetc">#ungetc</a>
    <li ><a href="#method-i-write">#write</a>
    <li ><a href="#method-i-write_nonblock">#write_nonblock</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-OpenSSL::Buffering">
    <h1 id="module-OpenSSL::Buffering" class="module">
      module OpenSSL::Buffering
    </h1>

    <section class="description">
    
<p><a href="../OpenSSL.html"><code>OpenSSL</code></a> <a href="../IO.html"><code>IO</code></a> buffering mix-in module.</p>

<p>This module allows an <a href="SSL/SSLSocket.html"><code>OpenSSL::SSL::SSLSocket</code></a> to behave like an <a href="../IO.html"><code>IO</code></a>.</p>

<p>You typically won’t use this module directly, you can see it implemented in <a href="SSL/SSLSocket.html"><code>OpenSSL::SSL::SSLSocket</code></a>.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="BLOCK_SIZE">BLOCK_SIZE
          <dd><p>Default size to read from or write to the SSLSocket for buffer operations.</p>
        </dl>
        </section>

        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-sync" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">sync</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>The “sync mode” of the SSLSocket.</p>

<p>See IO#sync for full details.</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(*)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an instance of OpenSSL’s buffering <a href="../IO.html"><code>IO</code></a> module.</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 63</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-operator">*</span>)
  <span class="ruby-keyword">super</span>
  <span class="ruby-ivar">@eof</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@rbuffer</span> = <span class="ruby-constant">Buffer</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-ivar">@sync</span> = <span class="ruby-ivar">@io</span>.<span class="ruby-identifier">sync</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-3C-3C" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">&lt;&lt;</span><span
                                class="method-args">(s)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes <em>s</em> to the stream.  <em>s</em> will be converted to a String using <code>.to_s</code> method.</p>

                              <div class="method-source-code" id="3C-3C-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 419</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">&lt;&lt;</span>(<span class="ruby-identifier">s</span>)
  <span class="ruby-identifier">do_write</span>(<span class="ruby-identifier">s</span>)
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-close" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">close</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Closes the SSLSocket and flushes any unwritten data.</p>

                              <div class="method-source-code" id="close-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 480</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">close</span>
  <span class="ruby-identifier">flush</span> <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">sysclose</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each</span><span
                                class="method-args">(eol=$/) { |line| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Executes the block for every line in the stream where lines are separated by <em>eol</em>.</p>

<p>See also <a href="Buffering.html#method-i-gets"><code>gets</code></a></p>

                              <div class="method-source-code" id="each-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 256</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each</span>(<span class="ruby-identifier">eol</span>=<span class="ruby-identifier">$/</span>)
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">gets</span>(<span class="ruby-identifier">eol</span>)
    <span class="ruby-keyword">yield</span> <span class="ruby-identifier">line</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Buffering.html#method-i-each_line">each_line</a>
                            </div>

                          </div>

                  <div id="method-i-each_byte" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each_byte</span><span
                                class="method-args">() { |byte| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Calls the given block once for each byte in the stream.</p>

                              <div class="method-source-code" id="each_byte-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 297</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_byte</span> <span class="ruby-comment"># :yields: byte</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">c</span> = <span class="ruby-identifier">getc</span>
    <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">ord</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each_line" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">each_line</span><span
                                class="method-args">(eol=$/)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Buffering.html#method-i-each">each</a>
                            </div>
                          </div>

                  <div id="method-i-eof" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">eof</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Buffering.html#method-i-eof-3F">eof?</a>
                            </div>
                          </div>

                  <div id="method-i-eof-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">eof?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if the stream is at file which means there is no more data to be read.</p>

                              <div class="method-source-code" id="eof-3F-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 328</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">eof?</span>
  <span class="ruby-identifier">fill_rbuff</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@eof</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@rbuffer</span>.<span class="ruby-identifier">empty?</span>
  <span class="ruby-ivar">@eof</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@rbuffer</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Buffering.html#method-i-eof">eof</a>
                            </div>

                          </div>

                  <div id="method-i-flush" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">flush</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Flushes buffered data to the SSLSocket.</p>

                              <div class="method-source-code" id="flush-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 468</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">flush</span>
  <span class="ruby-identifier">osync</span> = <span class="ruby-ivar">@sync</span>
  <span class="ruby-ivar">@sync</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-identifier">do_write</span> <span class="ruby-string">&quot;&quot;</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>
<span class="ruby-keyword">ensure</span>
  <span class="ruby-ivar">@sync</span> = <span class="ruby-identifier">osync</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-getbyte" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          getbyte &rarr; 81
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Get the next 8bit byte from ‘ssl`.  Returns `nil` on EOF</p>

                              <div class="method-source-code" id="getbyte-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 106</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">getbyte</span>
  <span class="ruby-identifier">read</span>(<span class="ruby-value">1</span>)&amp;.<span class="ruby-identifier">ord</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-getc" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">getc</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads one character from the stream.  Returns nil if called at end of file.</p>

                              <div class="method-source-code" id="getc-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 290</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">getc</span>
  <span class="ruby-identifier">read</span>(<span class="ruby-value">1</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-gets" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">gets</span><span
                                class="method-args">(eol=$/, limit=nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads the next “line” from the stream.  Lines are separated by <em>eol</em>.  If <em>limit</em> is provided the result will not be longer than the given number of bytes.</p>

<p><em>eol</em> may be a String or Regexp.</p>

<p>Unlike IO#gets the line read will not be assigned to +$_+.</p>

<p>Unlike IO#gets the separator must be provided if a limit is provided.</p>

                              <div class="method-source-code" id="gets-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 232</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">gets</span>(<span class="ruby-identifier">eol</span>=<span class="ruby-identifier">$/</span>, <span class="ruby-identifier">limit</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">idx</span> = <span class="ruby-ivar">@rbuffer</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">eol</span>)
  <span class="ruby-keyword">until</span> <span class="ruby-ivar">@eof</span>
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">idx</span>
    <span class="ruby-identifier">fill_rbuff</span>
    <span class="ruby-identifier">idx</span> = <span class="ruby-ivar">@rbuffer</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">eol</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">eol</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Regexp</span>)
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">idx</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">idx</span><span class="ruby-operator">+</span><span class="ruby-node">$&amp;</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">size</span> = <span class="ruby-identifier">idx</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">idx</span><span class="ruby-operator">+</span><span class="ruby-identifier">eol</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">limit</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">limit</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span>
    <span class="ruby-identifier">size</span> = [<span class="ruby-identifier">size</span>, <span class="ruby-identifier">limit</span>].<span class="ruby-identifier">min</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">consume_rbuff</span>(<span class="ruby-identifier">size</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-print" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">print</span><span
                                class="method-args">(*args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes <em>args</em> to the stream.</p>

<p>See IO#print for full details.</p>

                              <div class="method-source-code" id="print-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 447</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">print</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">s</span> = <span class="ruby-constant">Buffer</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">to_s</span> }
  <span class="ruby-identifier">do_write</span>(<span class="ruby-identifier">s</span>)
  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-printf" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">printf</span><span
                                class="method-args">(s, *args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Formats and writes to the stream converting parameters under control of the format string.</p>

<p>See Kernel#sprintf for format string details.</p>

                              <div class="method-source-code" id="printf-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 460</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">printf</span>(<span class="ruby-identifier">s</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">do_write</span>(<span class="ruby-identifier">s</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-puts" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">puts</span><span
                                class="method-args">(*args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes <em>args</em> to the stream along with a record separator.</p>

<p>See IO#puts for full details.</p>

                              <div class="method-source-code" id="puts-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 429</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">puts</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">s</span> = <span class="ruby-constant">Buffer</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\n&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-identifier">s</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp">/(?&lt;!\n)\z/</span>, <span class="ruby-string">&quot;\n&quot;</span>)
  }
  <span class="ruby-identifier">do_write</span>(<span class="ruby-identifier">s</span>)
  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read</span><span
                                class="method-args">(size=nil, buf=nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads <em>size</em> bytes from the stream.  If <em>buf</em> is provided it must reference a string which will receive the data.</p>

<p>See IO#read for full details.</p>

                              <div class="method-source-code" id="read-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 116</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read</span>(<span class="ruby-identifier">size</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">buf</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">buf</span>
      <span class="ruby-identifier">buf</span>.<span class="ruby-identifier">clear</span>
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">buf</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">return</span> <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">until</span> <span class="ruby-ivar">@eof</span>
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-ivar">@rbuffer</span>.<span class="ruby-identifier">size</span>
    <span class="ruby-identifier">fill_rbuff</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">consume_rbuff</span>(<span class="ruby-identifier">size</span>) <span class="ruby-operator">||</span> <span class="ruby-string">&quot;&quot;</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">buf</span>
    <span class="ruby-identifier">buf</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">ret</span>)
    <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">buf</span>
  <span class="ruby-keyword">end</span>
  (<span class="ruby-identifier">size</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">ret</span>.<span class="ruby-identifier">empty?</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">ret</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_nonblock" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_nonblock</span><span
                                class="method-args">(maxlen, buf=nil, exception: true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads at most <em>maxlen</em> bytes in the non-blocking manner.</p>

<p>When no data can be read without blocking it raises <a href="SSL/SSLError.html"><code>OpenSSL::SSL::SSLError</code></a> extended by <a href="../IO/WaitReadable.html"><code>IO::WaitReadable</code></a> or <a href="../IO/WaitWritable.html"><code>IO::WaitWritable</code></a>.</p>

<p><a href="../IO/WaitReadable.html"><code>IO::WaitReadable</code></a> means <a href="SSL.html"><code>SSL</code></a> needs to read internally so <a href="Buffering.html#method-i-read_nonblock"><code>read_nonblock</code></a> should be called again when the underlying <a href="../IO.html"><code>IO</code></a> is readable.</p>

<p><a href="../IO/WaitWritable.html"><code>IO::WaitWritable</code></a> means <a href="SSL.html"><code>SSL</code></a> needs to write internally so <a href="Buffering.html#method-i-read_nonblock"><code>read_nonblock</code></a> should be called again after the underlying <a href="../IO.html"><code>IO</code></a> is writable.</p>

<p><a href="Buffering.html#method-i-read_nonblock"><code>OpenSSL::Buffering#read_nonblock</code></a> needs two rescue clause as follows:</p>

<pre class="ruby"><span class="ruby-comment"># emulates blocking read (readpartial).</span>
<span class="ruby-keyword">begin</span>
  <span class="ruby-identifier">result</span> = <span class="ruby-identifier">ssl</span>.<span class="ruby-identifier">read_nonblock</span>(<span class="ruby-identifier">maxlen</span>)
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitReadable</span>
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>([<span class="ruby-identifier">io</span>])
  <span class="ruby-keyword">retry</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitWritable</span>
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>(<span class="ruby-keyword">nil</span>, [<span class="ruby-identifier">io</span>])
  <span class="ruby-keyword">retry</span>
<span class="ruby-keyword">end</span>
</pre>

<p>Note that one reason that <a href="Buffering.html#method-i-read_nonblock"><code>read_nonblock</code></a> writes to the underlying <a href="../IO.html"><code>IO</code></a> is when the peer requests a new TLS/SSL handshake.  See openssl the FAQ for more details.  <a href="http://www.openssl.org/support/faq.html">www.openssl.org/support/faq.html</a></p>

<p>By specifying a keyword argument <em>exception</em> to <code>false</code>, you can indicate that <a href="Buffering.html#method-i-read_nonblock"><code>read_nonblock</code></a> should not raise an IO::Wait*able exception, but return the symbol <code>:wait_writable</code> or <code>:wait_readable</code> instead. At EOF, it will return <code>nil</code> instead of raising EOFError.</p>

                              <div class="method-source-code" id="read_nonblock-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 201</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_nonblock</span>(<span class="ruby-identifier">maxlen</span>, <span class="ruby-identifier">buf</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-value">exception:</span> <span class="ruby-keyword">true</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">maxlen</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">buf</span>
      <span class="ruby-identifier">buf</span>.<span class="ruby-identifier">clear</span>
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">buf</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">return</span> <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rbuffer</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">sysread_nonblock</span>(<span class="ruby-identifier">maxlen</span>, <span class="ruby-identifier">buf</span>, <span class="ruby-value">exception:</span> <span class="ruby-identifier">exception</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">consume_rbuff</span>(<span class="ruby-identifier">maxlen</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">buf</span>
    <span class="ruby-identifier">buf</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">ret</span>)
    <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">buf</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ret</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-readchar" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">readchar</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads a one-character string from the stream.  Raises an EOFError at end of file.</p>

                              <div class="method-source-code" id="readchar-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 307</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">readchar</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">EOFError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">eof?</span>
  <span class="ruby-identifier">getc</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-readline" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">readline</span><span
                                class="method-args">(eol=$/)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads a line from the stream which is separated by <em>eol</em>.</p>

<p>Raises EOFError if at end of file.</p>

                              <div class="method-source-code" id="readline-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 281</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">readline</span>(<span class="ruby-identifier">eol</span>=<span class="ruby-identifier">$/</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">EOFError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">eof?</span>
  <span class="ruby-identifier">gets</span>(<span class="ruby-identifier">eol</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-readlines" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">readlines</span><span
                                class="method-args">(eol=$/)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads lines from the stream which are separated by <em>eol</em>.</p>

<p>See also <a href="Buffering.html#method-i-gets"><code>gets</code></a></p>

                              <div class="method-source-code" id="readlines-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 268</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">readlines</span>(<span class="ruby-identifier">eol</span>=<span class="ruby-identifier">$/</span>)
  <span class="ruby-identifier">ary</span> = []
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">gets</span>(<span class="ruby-identifier">eol</span>)
    <span class="ruby-identifier">ary</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ary</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-readpartial" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">readpartial</span><span
                                class="method-args">(maxlen, buf=nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads at most <em>maxlen</em> bytes from the stream.  If <em>buf</em> is provided it must reference a string which will receive the data.</p>

<p>See IO#readpartial for full details.</p>

                              <div class="method-source-code" id="readpartial-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 143</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">readpartial</span>(<span class="ruby-identifier">maxlen</span>, <span class="ruby-identifier">buf</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">maxlen</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">buf</span>
      <span class="ruby-identifier">buf</span>.<span class="ruby-identifier">clear</span>
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">buf</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">return</span> <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rbuffer</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">sysread</span>(<span class="ruby-identifier">maxlen</span>, <span class="ruby-identifier">buf</span>)
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EAGAIN</span>
      <span class="ruby-keyword">retry</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">consume_rbuff</span>(<span class="ruby-identifier">maxlen</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">buf</span>
    <span class="ruby-identifier">buf</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">ret</span>)
    <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">buf</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ret</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-ungetc" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ungetc</span><span
                                class="method-args">(c)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Pushes character <em>c</em> back onto the stream such that a subsequent buffered character read will return it.</p>

<p>Unlike IO#getc multiple bytes may be pushed back onto the stream.</p>

<p>Has no effect on unbuffered reads (such as sysread).</p>

                              <div class="method-source-code" id="ungetc-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 320</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ungetc</span>(<span class="ruby-identifier">c</span>)
  <span class="ruby-ivar">@rbuffer</span>[<span class="ruby-value">0</span>,<span class="ruby-value">0</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">chr</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write</span><span
                                class="method-args">(*s)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes <em>s</em> to the stream.  If the argument is not a String it will be converted using <code>.to_s</code> method.  Returns the number of bytes written.</p>

                              <div class="method-source-code" id="write-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 366</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">s</span>)
  <span class="ruby-identifier">s</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">written</span>, <span class="ruby-identifier">str</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">do_write</span>(<span class="ruby-identifier">str</span>)
    <span class="ruby-identifier">written</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">bytesize</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_nonblock" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_nonblock</span><span
                                class="method-args">(s, exception: true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes <em>s</em> in the non-blocking manner.</p>

<p>If there is buffered data, it is flushed first.  This may block.</p>

<p><a href="Buffering.html#method-i-write_nonblock"><code>write_nonblock</code></a> returns number of bytes written to the <a href="SSL.html"><code>SSL</code></a> connection.</p>

<p>When no data can be written without blocking it raises <a href="SSL/SSLError.html"><code>OpenSSL::SSL::SSLError</code></a> extended by <a href="../IO/WaitReadable.html"><code>IO::WaitReadable</code></a> or <a href="../IO/WaitWritable.html"><code>IO::WaitWritable</code></a>.</p>

<p><a href="../IO/WaitReadable.html"><code>IO::WaitReadable</code></a> means <a href="SSL.html"><code>SSL</code></a> needs to read internally so <a href="Buffering.html#method-i-write_nonblock"><code>write_nonblock</code></a> should be called again after the underlying <a href="../IO.html"><code>IO</code></a> is readable.</p>

<p><a href="../IO/WaitWritable.html"><code>IO::WaitWritable</code></a> means <a href="SSL.html"><code>SSL</code></a> needs to write internally so <a href="Buffering.html#method-i-write_nonblock"><code>write_nonblock</code></a> should be called again after underlying <a href="../IO.html"><code>IO</code></a> is writable.</p>

<p>So <a href="Buffering.html#method-i-write_nonblock"><code>OpenSSL::Buffering#write_nonblock</code></a> needs two rescue clause as follows.</p>

<pre class="ruby"><span class="ruby-comment"># emulates blocking write.</span>
<span class="ruby-keyword">begin</span>
  <span class="ruby-identifier">result</span> = <span class="ruby-identifier">ssl</span>.<span class="ruby-identifier">write_nonblock</span>(<span class="ruby-identifier">str</span>)
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitReadable</span>
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>([<span class="ruby-identifier">io</span>])
  <span class="ruby-keyword">retry</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitWritable</span>
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>(<span class="ruby-keyword">nil</span>, [<span class="ruby-identifier">io</span>])
  <span class="ruby-keyword">retry</span>
<span class="ruby-keyword">end</span>
</pre>

<p>Note that one reason that <a href="Buffering.html#method-i-write_nonblock"><code>write_nonblock</code></a> reads from the underlying <a href="../IO.html"><code>IO</code></a> is when the peer requests a new TLS/SSL handshake.  See the openssl FAQ for more details.  <a href="http://www.openssl.org/support/faq.html">www.openssl.org/support/faq.html</a></p>

<p>By specifying a keyword argument <em>exception</em> to <code>false</code>, you can indicate that <a href="Buffering.html#method-i-write_nonblock"><code>write_nonblock</code></a> should not raise an IO::Wait*able exception, but return the symbol <code>:wait_writable</code> or <code>:wait_readable</code> instead.</p>

                              <div class="method-source-code" id="write_nonblock-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 410</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_nonblock</span>(<span class="ruby-identifier">s</span>, <span class="ruby-value">exception:</span> <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">flush</span>
  <span class="ruby-identifier">syswrite_nonblock</span>(<span class="ruby-identifier">s</span>, <span class="ruby-value">exception:</span> <span class="ruby-identifier">exception</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-consume_rbuff" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">consume_rbuff</span><span
                                class="method-args">(size=nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Consumes <em>size</em> bytes from the buffer</p>

                              <div class="method-source-code" id="consume_rbuff-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 91</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">consume_rbuff</span>(<span class="ruby-identifier">size</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rbuffer</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">size</span> = <span class="ruby-ivar">@rbuffer</span>.<span class="ruby-identifier">size</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">size</span>
    <span class="ruby-ivar">@rbuffer</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">size</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-do_write" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">do_write</span><span
                                class="method-args">(s)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes <em>s</em> to the buffer.  When the buffer is full or <a href="Buffering.html#attribute-i-sync"><code>sync</code></a> is true the buffer is flushed to the underlying socket.</p>

                              <div class="method-source-code" id="do_write-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 343</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">do_write</span>(<span class="ruby-identifier">s</span>)
  <span class="ruby-ivar">@wbuffer</span> = <span class="ruby-constant">Buffer</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">unless</span> <span class="ruby-keyword">defined?</span> <span class="ruby-ivar">@wbuffer</span>
  <span class="ruby-ivar">@wbuffer</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">s</span>
  <span class="ruby-ivar">@wbuffer</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">BINARY</span>)
  <span class="ruby-ivar">@sync</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@sync</span> <span class="ruby-keyword">or</span> <span class="ruby-ivar">@wbuffer</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">BLOCK_SIZE</span>
    <span class="ruby-keyword">until</span> <span class="ruby-ivar">@wbuffer</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">nwrote</span> = <span class="ruby-identifier">syswrite</span>(<span class="ruby-ivar">@wbuffer</span>)
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EAGAIN</span>
        <span class="ruby-keyword">retry</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-ivar">@wbuffer</span>[<span class="ruby-value">0</span>, <span class="ruby-identifier">nwrote</span>] = <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fill_rbuff" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fill_rbuff</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Fills the buffer from the underlying SSLSocket</p>

                              <div class="method-source-code" id="fill_rbuff-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/buffering.rb, line 78</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fill_rbuff</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-ivar">@rbuffer</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">sysread</span>(<span class="ruby-constant">BLOCK_SIZE</span>)
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EAGAIN</span>
    <span class="ruby-keyword">retry</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">EOFError</span>
    <span class="ruby-ivar">@eof</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

